<?php

class Application_Model_DbTable_Shop extends Zend_Db_Table_Abstract
{

    protected $_name = 'Shop';
    public static $SHOP_PENDING = 0;
    public static $SHOP_ACCEPT = 1;
    public static $SHOP_REJECT = 2;



    /*
    public function getAll($where = null){
        $query = $this->select();
        $query->from(array('s'=>'Shop'));
        $query->joinInner(array('ms'=>'Membership_status'),'s.membership_id = ms.membership_id',array('ms_name'=>'name'));
        $query->setIntegrityCheck(false);
        if($where) $query->where($where);
        return $this->fetchAll($query);
    }
    */
    public function pdfToko($number,$page,$where = null,$order = null,$method = null){
        // start and end row to display
        $start = ($page - 1) * $number + 1;
        $end = $start + $number - 1 ;

        // WHERE clause
        $where = ($where)? " WHERE ".$where : "";

        // ORDER BY clause
        $order = ($order)? $order : "shop_id";
        $method = ($method)? $method : "ASC";


        $db = $this->getAdapter();
        $sql = "SELECT s.*, ms.name AS ms_name ".
            "FROM (SELECT rownumber = ROW_NUMBER() OVER (ORDER BY sh.$order $method), sh.* FROM Shop AS sh".$where.") as s ".
            "INNER JOIN Membership_status as ms ON s.membership_id = ms.membership_id ".
            "WHERE rownumber >= $start AND rownumber <= $end";
        $stmt = $db->query($sql);
        return $stmt->fetchAll();
    }

    

    

    
}

